<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
    <div class="btn-group hidden-xs" id="toolbar" role="group">
        <a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()"
           shiro:hasPermission="module:item:add">
            <i class="fa fa-plus"></i> add
        </a>
        <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()"
           shiro:hasPermission="module:item:remove">
            <i class="fa fa-trash-o"></i> delete
        </a>
    </div>

    <div class="col-sm-12 select-info table-striped">
        <table id="bootstrap-table" data-mobile-responsive="true"></table>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('module:item:edit')}]];
    var removeFlag = [[${@permission.hasPermi('module:item:remove')}]];
    var prefix = ctx + "module/item"

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "商品",
            columns: [{
                checkbox: true
            },
                {
                    field: 'itemId',
                    title: ''
                },
                {
                    field: 'itemName',
                    title: '物品名称',
                    width: '25%'
                },
                {
                    field: 'itemHref',
                    title: '商品链接',
                    width: '25%'
                },
                {
                    field: 'itemPrice',
                    title: '价格'
                },
                {
                    field: 'itemEan',
                    title: '商品EAN'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'updateTime',
                    title: '修改时间'
                },
                {
                    title: 'operation',
                    clickToSelect : false,
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.itemId + '\')"><i class="fa fa-edit"></i>edit</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.itemId + '\')"><i class="fa fa-remove"></i>delete</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>